package com.teamsun.mqtt.entity;

import io.netty.buffer.ByteBuf;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.concurrent.atomic.AtomicInteger;

public class MsgRep implements  Serializable{
    private Integer id;

    private Integer messageid;

    private String topname;

    private String sendiden;

    private byte[] content;
    
    static AtomicInteger atomicInteger=new AtomicInteger();
    
    
    
    public MsgRep(){
    	
    }

    public MsgRep(BigDecimal id, BigDecimal messageid, String topname, String sendiden) {
		super();
		this.id = id.intValue();
		this.messageid = messageid.intValue();
		this.topname = topname;
		this.sendiden = sendiden;
	}

	public MsgRep(Integer messageid, String topname, String sendiden,
    		ByteBuf byteBuf) {
		super();
		this.id=atomicInteger.incrementAndGet();
		this.messageid = messageid;
		this.topname = topname;
		this.sendiden = sendiden;
		content=new byte[byteBuf.readableBytes()];
		byteBuf.readBytes(content);
		byteBuf.resetReaderIndex();
	}

	public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public Integer getMessageid() {
        return messageid;
    }

    public void setMessageid(Integer messageid) {
        this.messageid = messageid;
    }

    public String getTopname() {
        return topname;
    }

    public void setTopname(String topname) {
        this.topname = topname == null ? null : topname.trim();
    }

    public String getSendiden() {
        return sendiden;
    }

    public void setSendiden(String sendiden) {
        this.sendiden = sendiden == null ? null : sendiden.trim();
    }

    public byte[] getContent() {
        return content;
    }

    public void setContent(byte[] content) {
        this.content = content;
    }


	public static AtomicInteger getAtomicInteger() {
		return atomicInteger;
	}

	public static void setAtomicInteger(AtomicInteger atomicInteger) {
		MsgRep.atomicInteger = atomicInteger;
	}
	
    
}